package 剑指offer;

import java.util.Arrays;

public class 找数组中出现奇数次的两个数 {
    public static void main(String[] args) {
        int[] arr = new int[]{1,2,1,3};
        int[] arr1 = new int[]{1,2,1,3,2,4};
//        System.out.println(Arrays.toString(find(arr)));
        System.out.println(Arrays.toString(find(arr1)));
    }
    public static int[] find(int[] arr){
        int temp1 = 0;
        int temp2 = 0;
        for (int i = 0; i < arr.length; i++) {
            temp1 ^= arr[i];
            temp2 = ~(temp2 ^ arr[i]);
        }
        int res1 = temp1 ^ temp2;
        int res2 = temp1 ^ res1;
        return new int[]{res1,res2};
    }
}
